<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DisplayModePlugin</title>
    <link
      rel="shortcut icon"
      type="image/x-icon"
      href="/examples/public/favicon.ico"
    />
    <link rel="stylesheet" href="../css/common.css" />
  </head>

  <style>
    #app {
      width: 100%;
      height: 100%;
    }

    #button-position {
      position: fixed;
      top: 30px;
      left: 50%;
    }

    #button-group {
      transform: translate(-50%, 0);
    }

    #button-group p {
      color: white;
    }

    #button-group button {
      margin: 0 5px;
      font-size: 16px;
      padding: 8px 10px;
      background: rgb(237, 75, 243);
      border-radius: 3px;
      box-shadow: 0 0 6px rgb(236, 182, 238);
    }
  </style>

  <body>
    <div id="app"></div>
    <div id="button-position">
      <div id="button-group">
        <p>change DisplayMode:</p>
      </div>
    </div>

    <script type="module">
      import * as THREE from "three";
      import * as Vis from "../../dist/Vis.es.js";

      const engine = new Vis.DisplayEngine()
        .install("DisplayMode")
        .complete()
        .setDom(document.getElementById("app"))
        .setSize()
        .play();

      const scene = engine.scene;

      const background = new THREE.CubeTextureLoader()
        .setPath("/examples/public/texture/skyBox/snowVillage/")
        .load(["px.jpg", "nx.jpg", "py.jpg", "ny.jpg", "pz.jpg", "nz.jpg"]);

      scene.background = background;

      const box = new THREE.Mesh(
        new THREE.BoxBufferGeometry(10, 10, 10),
        new THREE.MeshStandardMaterial({ color: "rgb(255, 105, 100)" })
      );
      box.position.x = 10;
      scene.add(box);

      const pointLight = new THREE.PointLight("rgb(255, 255, 255)", 1, 300, 0);
      pointLight.position.y = 30;
      scene.add(pointLight);

      const line = new THREE.Line(
        box.geometry,
        new THREE.LineBasicMaterial({ color: "yellow" })
      );
      scene.add(line);

      const points = new THREE.Points(
        box.geometry,
        new THREE.PointsMaterial({ color: "blue" })
      );

      points.position.x = -10;
      scene.add(points);

      const buttonGroup = document.getElementById("button-group");
      Object.keys(Vis.DISPLAYMODE).forEach((key) => {
        const buttonDom = document.createElement("button");
        buttonDom.innerText = Vis.DISPLAYMODE[key];
        buttonDom.onclick = () => {
          engine.setDisplayMode(Vis.DISPLAYMODE[key]);
        };

        buttonGroup.appendChild(buttonDom);
      });
    </script>
  </body>
</html>
